package model.domain;


import java.util.HashSet;
import java.util.Set;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;


@Entity
@Table(name = "project", catalog = "scrum")
public class Project implements java.io.Serializable {

	private static final long serialVersionUID = 1L;
	private Integer projectID;
	private String projectName;
	private Set<Impediment> impediments = new HashSet<Impediment>(0);
	private Set<ProjectParticipation> projectparticipations = new HashSet<ProjectParticipation>(0);
	private Set<Sprint> sprints = new HashSet<Sprint>(0);
	private Set<Product> productbacklogs = new HashSet<Product>(0);

	public Project() {
	}

	public Project(String cprojectName, Set impediments,
			Set projectparticipations, Set sprints, Set productbacklogs) {
		this.projectName = cprojectName;
		this.impediments = impediments;
		this.projectparticipations = projectparticipations;
		this.sprints = sprints;
		this.productbacklogs = productbacklogs;
	}

	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "nProjectID", unique = true, nullable = false)
	public Integer getProjectID() {
		return this.projectID;
	}

	public void setProjectID(Integer nprojectId) {
		this.projectID = nprojectId;
	}

	@Column(name = "cProjectName", length = 30)
	public String getProjectName() {
		return this.projectName;
	}

	public void setProjectName(String cprojectName) {
		this.projectName = cprojectName;
	}

	@OneToMany(fetch = FetchType.EAGER, mappedBy = "project")
	public Set<Impediment> getImpediments() {
		return this.impediments;
	}

	public void setImpediments(Set<Impediment> impediments) {
		this.impediments = impediments;
	}

	@OneToMany(fetch = FetchType.EAGER, mappedBy = "project")
	public Set<ProjectParticipation> getProjectparticipations() {
		return this.projectparticipations;
	}

	public void setProjectparticipations(Set<ProjectParticipation> projectparticipations) {
		this.projectparticipations = projectparticipations;
	}

	@OneToMany(fetch = FetchType.EAGER, mappedBy = "project")
	public Set<Sprint> getSprints() {
		return this.sprints;
	}

	public void setSprints(Set<Sprint> sprints) {
		this.sprints = sprints;
	}

	@OneToMany(fetch = FetchType.EAGER, mappedBy = "project")
	public Set<Product> getProductbacklogs() {
		return this.productbacklogs;
	}

	public void setProductbacklogs(Set<Product> productbacklogs) {
		this.productbacklogs = productbacklogs;
	}



    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }

        if (getClass() != obj.getClass()) {
            return false;
        }
        final Project other = (Project) obj;
        if(this.projectID == null){
            if(other.getProjectID() != null){
                return false;
            }
        } else if(!this.projectID.equals(other.getProjectID())){
            return false;
        }
        return true;

    }
    
    @Override
    public int hashCode() {
        int hash = 7;
        hash = 47 * hash + (this.projectID != null ? this.projectID.hashCode() : 0);
        hash = 47 * hash + (this.projectName != null ? this.projectName.hashCode() : 0);
        return hash;
    }

}
